package com.sunriz.refreshhcdata.controller;

import com.sunriz.refreshhcdata.POJO.DispatchLog;
import com.sunriz.refreshhcdata.POJO.InfoStorageDO;
import com.sunriz.refreshhcdata.POJO.Result;
import com.sunriz.refreshhcdata.server.CompareServer;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * ClassName: CompareController
 * Package: com.sunriz.refreshhcdata.controller
 * Description:
 *
 * @Author BuTang
 * @Create 2024/10/16 14:26
 * @Version 1.0
 */
@RestController
@Slf4j
@RequestMapping("/compare")
public class CompareController {

    @Autowired
    CompareServer compareServer;


    /**
     * 开始比较 `info_storage` 和 `dispatch_log` 两个表内的数据
     * 更新上报数据数量到 表 `data_compare`
     * 比较结果写入 表 `data_compare`
     * @return
     */
    @GetMapping("/startCompare")
    public Result startCompare(@RequestParam String deviceCode){
        compareServer.startCompare(deviceCode);
        return Result.success();
    }

    /**
     * 下发时存储数据刀  `dispatch_log`
     * 更新下发数据数量到 表 `data_compare`
     * @return
     */
    @PostMapping("/dispatchLog")
    public Result dispatchLog(@RequestBody DispatchLog dispatchLog){
        compareServer.dispatchLog(dispatchLog);
        return Result.success();
    }

    /**
     * 上报的数据存储到 `dispatch_log` 中
     * @return
     */
    @PostMapping("/infoStorage")
    public Result infoStorage(@RequestBody InfoStorageDO infoStorageDO){
        compareServer.infoStorage(infoStorageDO);
        return Result.success();
    }

}
